deltas: Add and document no-deltas-in-summary config option
authorAlexander Larsson <alexl@redhat.com>
Tue, 1 Sep 2020 10:26:17 +0000 (12:26 +0200)
committerAlexander Larsson <alexl@redhat.com>
Fri, 23 Oct 2020 10:30:08 +0000 (12:30 +0200)
By default this is FALSE to keep existing clients working.

man/ostree.repo-config.xml
src/libostree/ostree-repo.c

index 7a01fc0172b12925f8d9705c9f61b7e954762d8d..e4984430b912bbc73913ec5d644881f464e4c313 100644 (file)
@@ -249,6 +249,20 @@ Boston, MA 02111-1307, USA.
         costly).
         </para></listitem>
       </varlistentry>
+
+      <varlistentry>
+        <term><varname>no-deltas-in-summary</varname></term>
+        <listitem><para>Boolean value controlling whether OSTree should skip
+        putting an index of available deltas in the summary file. Defaults to false.
+        </para>
+        <para>
+        Since 2020.7 OSTree can use delta indexes outside the summary file,
+        making the summary file smaller (especially for larger repositories). However
+        by default we still create the index in the summary file to make older clients
+        work. If you know all clients will be 2020.7 later you can enable this to
+        save network bandwidth.
+        </para></listitem>
+      </varlistentry>
     </variablelist>
   </refsect1>
 
index 3a331c903af95dd46d65ca08eab7bc260fb4733c..9d9146b3a55a582458fd8faf21e442c1185d25d4 100644 (file)
@@ -5749,6 +5749,8 @@ ostree_repo_regenerate_summary (OstreeRepo     *self,
    * commits from working.
    */
   g_autoptr(OstreeRepoAutoLock) lock = NULL;
+  gboolean no_deltas_in_summary = FALSE;
+
   lock = _ostree_repo_auto_lock_push (self, OSTREE_REPO_LOCK_EXCLUSIVE,
                                       cancellable, error);
   if (!lock)
@@ -5781,35 +5783,41 @@ ostree_repo_regenerate_summary (OstreeRepo     *self,
       }
   }
 
-  {
-    g_autoptr(GPtrArray) delta_names = NULL;
-    g_auto(GVariantDict) deltas_builder = OT_VARIANT_BUILDER_INITIALIZER;
+  if (!ot_keyfile_get_boolean_with_default (self->config, "core",
+                                            "no-deltas-in-summary", FALSE,
+                                            &no_deltas_in_summary, error))
+    return FALSE;
 
-    if (!ostree_repo_list_static_delta_names (self, &delta_names, cancellable, error))
-      return FALSE;
+  if (!no_deltas_in_summary)
+    {
+      g_autoptr(GPtrArray) delta_names = NULL;
+      g_auto(GVariantDict) deltas_builder = OT_VARIANT_BUILDER_INITIALIZER;
 
-    g_variant_dict_init (&deltas_builder, NULL);
-    for (guint i = 0; i < delta_names->len; i++)
-      {
-        g_autofree char *from = NULL;
-        g_autofree char *to = NULL;
-        GVariant *digest;
+      if (!ostree_repo_list_static_delta_names (self, &delta_names, cancellable, error))
+        return FALSE;
 
-        if (!_ostree_parse_delta_name (delta_names->pdata[i], &from, &to, error))
-          return FALSE;
+      g_variant_dict_init (&deltas_builder, NULL);
+      for (guint i = 0; i < delta_names->len; i++)
+        {
+          g_autofree char *from = NULL;
+          g_autofree char *to = NULL;
+          GVariant *digest;
 
-        digest = _ostree_repo_static_delta_superblock_digest (self,
-                                                              (from && from[0]) ? from : NULL,
-                                                              to, cancellable, error);
-        if (digest == NULL)
-          return FALSE;
+          if (!_ostree_parse_delta_name (delta_names->pdata[i], &from, &to, error))
+            return FALSE;
 
-        g_variant_dict_insert_value (&deltas_builder, delta_names->pdata[i], digest);
-      }
+          digest = _ostree_repo_static_delta_superblock_digest (self,
+                                                                (from && from[0]) ? from : NULL,
+                                                                to, cancellable, error);
+          if (digest == NULL)
+            return FALSE;
 
-    if (delta_names->len > 0)
-      g_variant_dict_insert_value (&additional_metadata_builder, OSTREE_SUMMARY_STATIC_DELTAS, g_variant_dict_end (&deltas_builder));
-  }
+          g_variant_dict_insert_value (&deltas_builder, delta_names->pdata[i], digest);
+        }
+
+      if (delta_names->len > 0)
+        g_variant_dict_insert_value (&additional_metadata_builder, OSTREE_SUMMARY_STATIC_DELTAS, g_variant_dict_end (&deltas_builder));
+    }
 
   {
     g_variant_dict_insert_value (&additional_metadata_builder, OSTREE_SUMMARY_LAST_MODIFIED,